home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_075 / comm / globals.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  13KB  |  415 lines

  1. /*    Comm  global storage allocation */
  2. /*  compiler directives to fetch the necessary header files */
  3. #include <exec/types.h>
  4.  
  5. #include <libraries/dos.h>
  6. #include <intuition/intuition.h>
  7. #include <exec/exec.h>
  8. #include <graphics/gfxbase.h>
  9. #include <graphics/regions.h>
  10. #include <graphics/copper.h>
  11. #include <graphics/gels.h>
  12. #include <devices/serial.h>
  13. #include <devices/keymap.h>
  14. #include <hardware/blit.h>
  15. #include <libraries/dosextens.h>
  16.  
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include "defines.h"
  20.  
  21. #define VERSION   "Comm 1.34 "
  22. #define DATE      " 04/09/87 "
  23.  
  24.  
  25. struct setup {
  26.    UBYTE  version[41];
  27.    UBYTE  date[12];
  28.    UBYTE  def_dir[41];
  29.    UBYTE  DefDir[41];
  30.    USHORT new_colors[4];
  31.    UBYTE  cap_name[41];
  32.    ULONG  priority;
  33.    UBYTE  prefbaud;
  34.    ULONG  titlebar;
  35.    ULONG  interlace;
  36.    int    numbuffs;
  37.    int    period;
  38.    int    volume;
  39.    int    cycles;
  40.    int    length;
  41.    int    keyload;
  42. } install = {
  43.    "Comm 1.34\0                             ",  /* version */
  44.    " 04/09/87  ",                              /* date */
  45.    "RAM:\0                                  ",  /* def_dir */
  46.    "SYS:\0                                  ",  /* DefDir */
  47.    { 0,0,0,0 },                                /* new_colors */
  48.    "RAM:Capture.Txt\0                       ",  /* cap_name */
  49.    1, TRUE,
  50.    0, 0, NUMBUFS, BEEP_PERIOD, 64, BEEPCYCLES, BEEPSIZE,0
  51. };
  52.  
  53. /*
  54.    defines required for phone library
  55.      library entry looks like this:
  56. name              number           baud    comment
  57. plink             652-0800         1200    accessed through tymnet
  58. >                 555-1212,,,12345         MCI gateway and account number
  59.  
  60. */
  61.  
  62. struct dir_entry {                     /* phone directory entry */
  63.                     char name[ NAMESIZE+1 ];
  64.                     char number[ NBRSIZE+1 ];
  65.                     char baud[ BAUDSIZE+1 ];
  66.                     char comment[ COMTSIZE+1 ];
  67.                  } pdir[ MAXPHONE ] ;
  68.  
  69. /*
  70. UBYTE  version[] = VERSION;
  71. UBYTE  date[]    = DATE;
  72. */
  73. UBYTE  alt_serv[ NBRSIZE+1 ];     /* alternate long distance service # */
  74. UBYTE  phl_empty[] = "Phone library empty\n";
  75. UBYTE  phonedir[ MAXFNAME ] = "\000";
  76. UBYTE  sbuff[120];                /* sprintf work buffer */
  77. UBYTE  buffer[BufSize];           /* ASCII capture buffer */
  78. UBYTE  xbuffer[SECSIZ];           /* XMODEM sector buffer */
  79. UBYTE  *diskbuff = NULL;          /* allocated XMODEM file buffer */
  80. /*
  81. UBYTE  def_dir[ 41 ] = "RAM:";
  82. */
  83. int   altservflg  = FALSE;
  84. int   numbufs;           /* number of disk buffers allocated */
  85.  
  86. unsigned
  87.     fd,                  /* XMODEM file being sent/received */
  88.     prt     = 0,         /* printer device */
  89.     sector,              /* sector being sent/received */
  90.     baud    = 1200,      /* current baud rate */
  91.     cancel  = FALSE,     /* TRUE if CAN received and abort_flag is TRUE */
  92.     abort   = FALSE,     /* TRUE if user aborts XMODEM xfers with ESC */
  93.     timeout = FALSE,     /* TRUE if timeout during character receive */
  94.     chopflg = TRUE,      /* TRUE if we CHOP files */
  95.     xonflg  = FALSE,     /* does driver do XON/XOFF? */
  96.     echoflg = FALSE;     /* TRUE to echo received characters to sender */
  97.  
  98. USHORT printon = FALSE;  /* TRUE if printing */
  99. USHORT capton  = FALSE;  /* TRUE if capturing */
  100. USHORT crcflag = TRUE;   /* TRUE if crc mode, FALSE for checksum */
  101.                          /* can be changed in send mode by remote receiver */
  102. USHORT xfrmode = TRUE;   /* same as crcflag, except only under user control */
  103. USHORT crc;              /* 16 bit crc value */
  104. UBYTE  checksum;
  105.  
  106. int viewflg      = FALSE; /* TRUE if XMODEM transfers are viewed on screen */
  107. int close_window = FALSE; /* TRUE if we have to close the split window */
  108. int debug        = FALSE; /* general debug flag */
  109. int asciiflg     = FALSE; /* TRUE to add CR/LF pairs to XMODEM send */
  110. int interlace    = FALSE;
  111.  
  112. short dcd        = 0;     /* state of modem Carrier Detect */
  113. short wxflag     = FALSE;
  114. short halfduplex = FALSE; /* TRUE if HalfDuplex mode */
  115. UWORD dos_version = 0;
  116.  
  117. UBYTE *keymacro[ KEYMACS ];
  118. UBYTE commkeys[ MAXFNAME ] = KEYFILE;
  119. UBYTE *capt_status;
  120.  
  121. extern struct Gadget Strgadget;
  122.  
  123. /*   Intuition always wants to see these declarations */
  124. struct IntuitionBase *IntuitionBase = NULL;
  125. struct GfxBase *GfxBase = NULL;
  126.  
  127. struct Screen       *commscreen = NULL;
  128. struct NewScreen    CommScreen =
  129.    {  0,0,640,200,2,
  130.       0,1,
  131.       HIRES | SPRITES,
  132.       CUSTOMSCREEN,
  133.       0,install.version,0,0
  134. };
  135.  
  136. extern struct MenuItem PlibItems[];
  137. struct Window       *rx_window  = NULL;     /* ptr to receive   window */
  138. struct Window       *tx_window  = NULL;     /* ptr to transmit  window */
  139. struct Window       *req_window = NULL;     /* ptr to requester window */
  140. struct Window       *vw_window  = NULL;     /* ptr to file view window */
  141. struct Window       *stat_window= NULL;     /* ptr to status window */
  142. struct Window       *st_window  = NULL;
  143.  
  144. struct Gadget tx_window_close  = {
  145.       NULL,             /* next gadget in list */
  146.       0,0,              /* left, top edge of hit box */
  147.       20,9,             /* width, height of hit box  */
  148.       GADGHCOMP,        /* flags */
  149.       RELVERIFY,        /* activation */
  150.       BOOLGADGET,       /* gadget type */
  151.       NULL,             /* rendering */
  152.       NULL,             /* select render */
  153.       NULL,             /* text for this gadget */
  154.       0,                /* Mutual exclude */
  155.       NULL,
  156.       0,0               /* user fields */
  157.       }, rx_window_close = {
  158.          NULL,0,0,20,9,GADGHCOMP,RELVERIFY,BOOLGADGET,NULL,NULL,NULL,
  159.          0,NULL,0,0};
  160.  
  161. struct Gadget tx_window_front = {
  162.       NULL,             /* next gadget in list */
  163.       620,0,            /* left, top edge of hit box */
  164.       20,9,             /* width, height of hit box  */
  165.       GADGHCOMP,        /* flags */
  166.       RELVERIFY,        /* activation */
  167.       BOOLGADGET,       /* gadget type */
  168.       NULL,             /* rendering */
  169.       NULL,             /* select render */
  170.       NULL,             /* text for this gadget */
  171.       0,                /* Mutual exclude */
  172.       NULL,
  173.       0,0               /* user fields */
  174.       }, rx_window_front = {
  175.          NULL,620,0,20,9,GADGHCOMP,RELVERIFY,BOOLGADGET,NULL,NULL,NULL,
  176.          0,NULL,0,0};
  177.  
  178.  
  179. struct Gadget tx_window_back = {
  180.       NULL,             /* next gadget in list */
  181.       595,0,            /* left, top edge of hit box */
  182.       20,9,             /* width, height of hit box  */
  183.       GADGHCOMP,        /* flags */
  184.       RELVERIFY,        /* activation */
  185.       BOOLGADGET,       /* gadget type */
  186.       NULL,             /* rendering */
  187.       NULL,             /* select render */
  188.       NULL,             /* text for this gadget */
  189.       0,                /* Mutual exclude */
  190.       NULL,
  191.       0,0               /* user fields */
  192.       }, rx_window_back = {
  193.          NULL,595,0,20,9,GADGHCOMP,RELVERIFY,BOOLGADGET,NULL,NULL,NULL,
  194.          0,NULL,0,0};
  195.  
  196. #ifdef XYZ
  197. struct Image knob;
  198.  
  199. struct PropInfo propinfo = {
  200.    AUTOKNOB | FREEHORIZ,
  201.    0,0,
  202.    MAXPOT / 10,0,
  203.    0,0,0,0,0,0
  204. };
  205.  
  206.  
  207. struct Gadget delay_prop = {
  208.       NULL,                   /* next gadget */
  209.       110,15,                 /* left, top */
  210.       100,PROPSIZE-1,         /* width, height */
  211. GADGIMAGE | GADGHNONE,        /* Flags */
  212.       0,                      /* Activation */
  213.       PROPGADGET,             /* type */
  214.       (APTR)&knob,            /* render */
  215.       NULL,                   /* select render */
  216.       NULL,                   /* text */
  217.       NULL,                   /* mutual exclude */
  218.       (APTR)&propinfo,        /* special info */
  219.       NULL,                   /* id */
  220.       NULL                    /* user info */
  221. };
  222. #endif
  223. struct IntuiMessage *NewMessage = NULL;    /* msg structure for GetMsg() */
  224. int    split_screen = FALSE;               /* TRUE if 2 screens FALSE if 1 */
  225.  
  226. /* RX window structure */
  227. struct NewWindow RXWindow = {
  228.    0, 0, 640, 190,
  229.    0, 1,
  230.    NULL,  /* use TX window IDCMP */
  231.    BORDERLESS | NOCAREREFRESH | SMART_REFRESH | BACKDROP,
  232.    NULL, NULL,
  233.    NULL,
  234.    NULL, NULL,
  235.    0,148,0,0,   /* I use MinHeight for Split Screen Height */
  236.    CUSTOMSCREEN
  237. };
  238.  
  239. /* status window structure */
  240. struct NewWindow STWindow = {
  241.    0, 190, 640,10,
  242.    0, 1,
  243.    NULL,  /* use TX window IDCMP */
  244.    BORDERLESS | NOCAREREFRESH | SMART_REFRESH | BACKDROP,
  245.    NULL, NULL,
  246.    NULL,
  247.    NULL, NULL,
  248.    0,0,0,0,
  249.    CUSTOMSCREEN
  250. };
  251.  
  252. /* TX window structure */
  253. struct NewWindow TXWindow = {
  254.    0, 0, 640, 190,
  255.    0, 1,
  256.    CLOSEWINDOW | MENUPICK | RAWKEY | GADGETUP,
  257.    BORDERLESS  | NOCAREREFRESH | SMART_REFRESH | ACTIVATE | BACKDROP,
  258.    NULL, NULL,
  259.    NULL,
  260.    NULL, NULL,
  261.    0,43,0,0,   /* I use MinHeight for Split screen height */
  262.    CUSTOMSCREEN
  263. };
  264.  
  265. struct NewWindow VWindow = {     /* file view window */
  266.    10, 20, 600, 102,
  267.    0, 1,
  268.    NULL,  /* use TX window IDCMP */
  269.    SMART_REFRESH | NOCAREREFRESH | WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH
  270.    | WINDOWSIZING,
  271.    NULL, NULL,
  272.    (UBYTE *)"View Window",
  273.    NULL, NULL,
  274.    80, 30, 640, 160,
  275.    CUSTOMSCREEN
  276. };
  277.  
  278. struct NewWindow RQWindow = {
  279.    0, 0, REQWIDTH+5, REQHEIGHT+13,
  280.    0, 1,
  281.    NULL,       /* No IDCMP, we'll use the tx_window port */
  282.    WINDOWDRAG | NOCAREREFRESH | SMART_REFRESH | ACTIVATE,
  283.    NULL,
  284.    NULL,
  285.    (UBYTE *)"INPUT WINDOW",
  286.    NULL,
  287.    NULL,
  288.    0,0,0,0,
  289.    CUSTOMSCREEN
  290. };
  291.  
  292.  
  293. extern struct MenuItem  FileItems[], SysItems[], ModeItems[], SerialIems[],
  294.                         DebugItems[], PhoneItems[];
  295. extern struct IntuiText FileText[], SysText[], ModeText[], SerialText[],
  296.                         DebugText[], EolText[], BaudText[],
  297.                         ParityText[], LengthText[], StopText[],
  298.                         DuplexText[], AltFileText[], PhoneText[];
  299.  
  300. extern struct Menu menu[];
  301.  
  302. /* declarations for the serial stuff */
  303.  
  304. struct IOExtSer *Read_Request  = NULL;
  305. struct IOExtSer *Write_Request = NULL;
  306. struct IOExtSer *Echo_Request  = NULL;
  307.  
  308. UBYTE     rs_in[ RSBUFSIZ + 1 ];
  309. UBYTE     rs_out[2];
  310. UBYTE     rs_echo[2];
  311.  
  312. /* declarations for console device */
  313.  
  314. extern struct MsgPort  *CreatePort();
  315. extern struct IOStdReq *CreateStdIO();
  316.  
  317. struct IOStdReq *tx_con    = NULL;
  318. struct IOStdReq *rx_con    = NULL;
  319. struct IOStdReq *st_con    = NULL;
  320. struct IOStdReq *vw_con    = NULL;
  321. struct MsgPort  *tx_con_mp = NULL;
  322. struct MsgPort  *rx_con_mp = NULL;
  323. struct MsgPort  *st_con_mp = NULL;
  324. struct MsgPort  *vw_con_mp = NULL;
  325.  
  326. /* Timer device allocation */
  327.  
  328. struct timerequest TimerIO;
  329. struct MsgPort TimerMsgPort;
  330.  
  331. /* requester allocation */
  332.  
  333. UBYTE enter_txt[]  = "ENTER ";
  334. UBYTE cancel_txt[] = "CANCEL";
  335. UBYTE ok_txt[]     = " OK ";
  336.  
  337. struct IntuiText  canceltext =
  338.       {
  339.          ORANGE,  /* front pen */
  340.          WHITE,   /* back pen  */
  341.          JAM2,    /* draw mode */
  342.          0,       /* left edge */
  343.          0,       /* top edge  */
  344.          0,       /* text font */
  345.        cancel_txt,/* text      */
  346.          NULL     /* next text */
  347.       };
  348.  
  349. struct IntuiText  Reqtext =
  350.       {
  351.          BLACK,WHITE,JAM2,51,-10,0,NULL,NULL
  352.       };
  353.  
  354. struct IntuiText  Entertxt =
  355.       {
  356.          BLACK,WHITE,JAM2,0,-10,0,enter_txt,&Reqtext
  357.       };
  358.  
  359. struct IntuiText  oktext =
  360.       {
  361.          BLACK,WHITE,JAM2,0,0,0,ok_txt,NULL
  362.       };
  363.  
  364. struct StringInfo string =
  365.     {
  366.       NULL,             /* buffer for input data */
  367.       NULL,             /* no undo buffer */
  368.       0,MAXFNAME,       /* position and max characters in buffer */
  369.       0,                /* position of first displayed character */
  370.       0,0,0,0,0,0,0,0
  371.     };
  372.  
  373. struct StringInfo Dirstr =
  374.     {
  375.       install.DefDir,NULL,0,40,0,0,0,0,0,0,0,0,0
  376.     };
  377.  
  378.  
  379. struct Gadget     Dirgadget =
  380.     {
  381.       NULL,             /* next gadget in list */
  382.       76,38,            /* left, top edge of hit box */
  383.       96,8,             /* width, height of hit box  */
  384.     GADGHCOMP,          /* flags */
  385. ENDGADGET | RELVERIFY,  /* activation */
  386.     STRGADGET,          /* gadget type */
  387.       NULL,             /* rendering */
  388.       NULL,             /* select render */
  389.       NULL,             /* text for this gadget */
  390.       0,                /* Mutual exclude */
  391.       (APTR)&Dirstr,    /* special info */
  392.       0,0               /* user fields */
  393.     };
  394.  
  395. struct Gadget     OKgadget =
  396.     {
  397.       NULL,16,38,32,8,GADGHCOMP,ENDGADGET | RELVERIFY,BOOLGADGET,NULL,
  398.       NULL,&oktext,0,NULL,0,0
  399.     };
  400.  
  401. struct Gadget     Cancelgadget =
  402.     {
  403.       NULL,200,38,48,8,GADGHCOMP,ENDGADGET | RELVERIFY,BOOLGADGET,NULL,
  404.       NULL,&canceltext,0,NULL,0,0
  405.     };
  406.  
  407. struct Gadget     Strgadget =
  408.     {
  409.       NULL,12,26,240,8,GADGHCOMP,ENDGADGET | RELVERIFY,STRGADGET,NULL,
  410.       NULL,&Entertxt,0,(APTR)&string,0,0
  411.     };
  412.  
  413. struct Process *this_process;
  414.  
  415.